#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <cstring>
#include <queue>
#include <climits>
using namespace std;

typedef pair<int, int> PII;
#define a first
#define b second

int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };

char arr[11][11];
size_t res[11][11];
bool sta[11][11];

void bfs()
{
    queue<PII> q;
    q.push(make_pair(1, 2));
    sta[1][2] = true;
    while (!q.empty())
    {
        int a = q.front().a, b = q.front().b;
        q.pop();
        for (int i = 0; i < 4; i++)
        {
            int x = dx[i] + a;
            int y = dy[i] + b;
            if (x >= 1 && x <= 10 && y >= 1 && y <= 10)
            {
                if (arr[x][y] == '.')
                {
                    if (!sta[x][y])
                    {
                        sta[x][y] = true;
                        res[x][y] = min(res[x][y], res[a][b] + 1);
                        q.push(make_pair(x, y));
                    }
                }
            }
        }
    }
    cout << res[10][9] << endl;
}

int main() {
    char c;
    while (cin >> c) {
        memset(sta, false, sizeof(sta));
        memset(res, INT_MAX, sizeof(res));
        for (int i = 1; i <= 10; i++) {
            for (int j = 1; j <= 10; j++) {
                if (i == 1 && j == 1)
                {
                    arr[i][j] = c;
                    continue;
                }
                cin >> arr[i][j];
            }
        }
        res[1][2] = 0;
        bfs();
    }

    return 0;
}